<?php
//公用函数
function panduan($array){
	foreach ($array as $key => $value) {
		if($value[0]){
			$rel = $value[0]($_POST[$key]);
			if(!$rel){
				if(empty($value[1])){
					return ['code' => 0,'msg' => $key.'不能为空'];	
				}else{
					return ['code' => 0,'msg' => $value[1]];
				}
			}
		}
	}
	return ['code' => 1];
}

//判断空
function kong($aa){
	if (empty($aa)) {
		return false;
	}
	return true;
}
//判断是否数字
function intss($aa){
	if (is_numeric($aa)) {
		return true;
	}
	return false;
}
//判断数组是否为空
function aray($aa){
	if (is_array($aa)) {
		return true;
	}
	return false;
}
//判断邮箱是否正确
function is_email($value){
	if ( isset($value))
	{
	    $email_address = $value;
	    $pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
	    if ( preg_match( $pattern, $email_address ) )
	    {
	    	return true;
	    }
	    else
	    {
	       return;
	    }
	}
}
//判断电话是否正确
function is_phone($value){
	if ( isset($value))
	{
	    $email_address = $value;
	    $pattern = "/^1[34578]\d{9}$/";
	    if ( preg_match( $pattern, $email_address ) )
	    {
	    	return true;
	    }
	    else
	    {
	       return;
	    }
	}
}
//判断身份证号是否正确
function is_id($value){
	if ( isset($value))
	{
	    $email_address = $value;
	    $pattern = "/^(\d{6})+(\d{4})+(\d{2})+(\d{2})+(\d{3})([0-9]|X)$/";
	    if ( preg_match( $pattern, $email_address ) )
	    {
	    	return true;
	    }
	    else
	    {
	       return;
	    }
	}
}

//调试
function dump($var){
    $output = print_r($var, true);
    $output = "<pre>" . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
    echo $output;
    exit();
}